package net.sf.xoperator.ui.txt;

import java.util.Collections;
import java.util.List;

import net.sf.xoperator.blackboard.NoPlanBlackBoardControl;

/**
 * a class for managing textual interactions.
 * 
 * @author joerg
 * 
 */
public class Interactor {
   
   private NoPlanBlackBoardControl control;

	public Interactor(List<Interaction> interac, NoPlanBlackBoardControl control) {
     
		this.interactions = interac;
      this.control = control;
	}

	private List<Interaction> interactions;

	private Dialogue currentDialogue = null;
   
   /**
    * 
    * @return an mudifiable list of the interactions of this interactor
    */
   public List<Interaction> getInteractions(){
      return Collections.unmodifiableList(this.interactions);
   }

	public boolean isInteraction(String input) {
		for (Interaction action : this.interactions) {
			if(input.startsWith(action.getKeyWord())){
				return true;
			}
		}
		return false;
	}

	/**
	 * 
	 * @return a response to the reaction
	 */
	public List<Object> performInteraction(String input) {

		for (Interaction action : this.interactions) {
			if(input.startsWith(action.getKeyWord())){
				return action.performInternal(input, this.control,this);
			}
		}
      //should never be the case, as 
		return null;
	}
   
   


}
